package com.xiaowan.user.controller;

import com.xiaowan.apis.user.EmergencyContactInfoControllerApi;
import com.xiaowan.model.common.dtos.ResponseResult;
import com.xiaowan.model.user.EmergencyContactInfo;
import com.xiaowan.user.service.EmergencyContactInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 实现功能：紧急联系人
 *
 * @author 作者[admin]
 * @version 1.0.00 2023-04-07 16:43
 */
@RestController
@RequestMapping("/emergencyContact")
public class EmergencyContactInfoController implements EmergencyContactInfoControllerApi {

    @Autowired
    EmergencyContactInfoService emergencyContactInfoService;

    @Override
    @PostMapping("/perfectMessage")
    public ResponseResult addMessage(@RequestBody List<EmergencyContactInfo> list) {
        emergencyContactInfoService.addMessage(list);
        return ResponseResult.okResult(200,"添加成功");
    }

    @Override
    @GetMapping("/findEmergencyContactInfoById/{id}")
    public List<EmergencyContactInfo> findEmergencyContactInfoById(Integer id) {
        return emergencyContactInfoService.findEmergencyContactInfoById(id);
    }

    @Override
    @PostMapping("/updateEmergencyContactInfo")
    public ResponseResult updateEmergencyContactInfo(@RequestBody EmergencyContactInfo emergencyContactInfo) {
        return emergencyContactInfoService.updateEmergencyContactInfo(emergencyContactInfo);
    }
}
